package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory1;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import com.atguigu.tingshu.vo.album.AlbumCategoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "分类管理")
@RestController
@RequestMapping(value = "/api/album")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {

    @Autowired
    private BaseCategoryService baseCategoryService;

    @GetMapping("/category/getBaseCategoryList")
    @Operation(summary = "获取分类列表")
    public Result<List<AlbumCategoryVo>> getBaseCategoryList() {
        return Result.ok(baseCategoryService.getAllBaseCategoryList());
    }

    @GetMapping("/category/findAllCategory1")
    @Operation(summary = "获取所有一级分类")
    public Result<List<BaseCategory1>> findAllCategory1() {
        return Result.ok(baseCategoryService.findAllCategory1());
    }

    @GetMapping("/category/findTopBaseCategory3/{categoryId}")
    @Operation(summary = "获取一级分类下的所有三级分类")
    public Result<List<BaseCategory3>> findTopBaseCategory3(@PathVariable(value = "categoryId") Long categoryId) {
        return Result.ok(baseCategoryService.findTopBaseCategory3(categoryId));
    }

    @GetMapping("/category/findAttribute/{category1Id}")
    @Operation(summary = "获取一级分类的属性以及属性值")
    public Result<List<BaseAttribute>> findAttribute(@PathVariable(value = "category1Id") Long category1Id) {
        return Result.ok(baseCategoryService.findAttribute(category1Id));
    }

    @GetMapping("/category/getBaseCategoryList/{category1Id}")
    @Operation(summary = "获取一级分类下的所有分类")
    public Result<AlbumCategoryVo> getBaseCategoryList(@PathVariable(value = "category1Id") Long category1Id) {
        return Result.ok(baseCategoryService.getBaseCategoryList(category1Id));
    }

    @GetMapping("/category/getCategoryView/{category3Id}")
    @Operation(summary = "根据三级分类标签获取分类信息")
    public Result<BaseCategoryView> getCategoryView(@PathVariable(value = "category3Id") Long category3Id) {
        return Result.ok(baseCategoryService.getCategoryView(category3Id));
    }
}
